import os
import anndata
import sys
import numpy as np
wd = '/home/clarice/Documents/SingleCell_PseudoTime/'
os.chdir(wd)
sys.path.append('extras/Stabilized_ICA')
#-- Read data
sc200 = anndata.read_h5ad('data/sc200CL_pp.h5ad')
ref_cell_line = 'JHU011_UPPER_AERODIGESTIVE_TRACT'
import scycle as cc
cc.pp.prep_pooling(sc200)
On this warning: Nothing I can do about it as of now, it's an internal error from anndata
cc.pp.score_cell_cycle(sc200)
Here we run the first steps of the pipeline on the reference:
scref = sc200[sc200.obs['Cell_line'] == ref_cell_line]
cc.tl.dimensionality_reduction(scref, method = 'ica', n_comps = 30, seed = 0)
cc.tl.enrich_components(scref)
And here comes the OT integration implemented by Aziz:
cc.tl.integration(sc200, scref)
cc.tl.principal_circle(sc200)
cc.pl.scatter_projection(sc200, col_var = 'Cancer_type', trajectory = True)
cc.pl.scatter_projection3d(sc200, col_var = 'Cancer_type', alpha = 0.3,
trajectory = True, size = 3, node_color = 'black', palette = 'Accent')
This is the clunkiest part of this pipeline, we may actually benefit from the alternative normalization based on the trajectory even if it was just to streamline this part.
cc.tl.celldiv_moment(sc200, var = 'total_counts')
cc.pl.scatter_projection(sc200, trajectory = True)
Total counts are kind of all over the place here. But there seems to be a bit of a gap around node 10?
cc.pl.scatter_projection(sc200, col_var = 'G1/S_score', trajectory = True)
cc.pl.scatter_projection(sc200, col_var = 'G2-M', trajectory = True)
cc.tl.remap_nodes(sc200, celldiv_edge = [10,11], cycle_direction = -1)
cc.tl.pseudotime(sc200)
cc.pl.hist_pseudotime(sc200)
cc.pl.scatter_cell_cycle(sc200)
cc.pl.scatter_cell_cycle(sc200, scores = 'components')
Of note, cc.tl.cell_cycle_phase already uses the curvature settings to find the cell cycle divisions.
cc.tl.cell_cycle_phase(sc200)
cc.pl.scatter_cell_cycle(sc200, scores = 'components', alpha = 0.1)
cc.tl.annotate_cell_cycle(sc200)
cc.pl.barplot_cycle_phase(sc200)
Considering making this a piechart? I'd use our alternative plotting system with plotly for that since plotnine doesn't currently support polar coordinates, unfortunetely.
cc.pl.scatter_projection3d(sc200, col_var = 'cell_cycle_phase', size = 3)